
version 13 
set more off, permanent

/****------------------****------------------****------------------****
Table 1: Descriptive statistics of lab in the field games
*****------------------****------------------****------------------****/

	use data/lab_sample, clear
	
* PREPARE TEXT FOR EACH LINE	
	label var trust_dum_own				"Subject sent a positive amount in the trust game"
	label var trust_dum_other			"Subject sent a positive amount in the trust game"

	label var trust_own					"Amount sent in the trust game"
	label var trust_other				"Amount sent in the trust game"
	
	label var trust_own_expected_dum	"Subject expects back the amount sent in the trust game"
	label var trust_other_expected_dum	"Subject expects back the amount sent in the trust game"
	
	label var trust_own_expected		"Share the subject expects to receive back in the trust game"
	label var trust_other_expected		"Share the subject expects to receive back in the trust game"
	
	label var dictator_dum_own			"Subject sent a positive amount in the dictator game"
	label var dictator_dum_other		"Subject sent a positive amount in the dictator game"

	label var dictator_own				"Amount sent in the dictator game"
	label var dictator_other			"Amount sent in the dictator game"
	
	label var gambles_rejected			"Risk aversion" 
	
* SUMMARY STATISTICS
	su trust_dum_own
	su trust_dum_other
	
	su trust_own
	su trust_other
	
	su trust_own_expected_dum
	su trust_other_expected_dum
	
	su trust_own_expected
	su trust_other_expected
	
	su dictator_dum_own
	su dictator_dum_other
	
	su dictator_own
	su dictator_other
	
	su gambles_rejected
	
	
/****------------------****------------------****------------------****
Table 2: Impact of interventions on interactions with the banker
*****------------------****------------------****------------------****/

	* bank transactions
	use data/admin_data, clear
	keep hhn_long n_dep1 n_with1
	merge 1:1 hhn_long using data/lab_sample
	keep if _merge==2 | _merge==3
	drop _merge
	egen n_tr1 = rowtotal(n_dep1 n_with1)
	* for new account holders: add two meetings to open and activate accounts
		replace n_tr1 = n_tr1 + 2 if hh_category==2
	* for new and old account holders: add training
		replace n_tr1 = n_tr1 + 1 if hh_category!=3
	* for paid into account: remove the deposits that we made
		replace n_tr1 = n_tr1-weeks if random_account==1
		gen trans = n_tr1 + shop_bcsa
	* xtset
		xtset village
	* prepare text for each line
		label var cat_bcsa_open			"New account"
		label var random_account 		"Paid into account"

/****------------------****
Table 2, Panel A 
*****------------------****/

	* Variables 
		local x1 cat_bcsa_open
		local x2a "random_account female"
		local x2b "random_account female sc obc fc same_caste age married readwrite_dum emp_agr emp_nonagr self_agr self_nonagr account_total shg_total land_amount dwelling_katcha bcsa_distance trust_strangers"
		local to_use "if hh_category>1"
		local se "vce(bootstrap, reps(400) seed(10101) nodots)"	
		local y1  n_tr1
		local y2  shop_bcsa
		estimates clear
	
	forvalues a = 1/2 {
	eststo: xtreg `y`a'' `x1' `x2a' `to_use', fe `se' 
		su `y`a'' if hh_category==3, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"No"
		estadd local  FE  		"Yes"
		
	eststo: xtreg `y`a'' `x1' `x2b' `to_use', fe `se' 
		su `y`a'' if hh_category==3, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"	
		}
	
	**** OUTPUT ****
	* screen
		esttab est*, b(2) p(2) scalars(N "r2 \(R^{2}\)" "Mean_control Average transactions of subjects without account" "FE Fixed Effects" "Control Control variables"  "p_cash_acc P-value paid in cash versus on the account") sfmt(0 2 1 0 0 2) nogaps star(* 0.1 ** 0.05 *** 0.01) 					

	* tex
		esttab est* using results/table2.tex, replace f ///
		label booktabs b(3) p(3) eqlabels(none) alignment(S S) collabels("\multicolumn{1}{c}{$\beta$ / SE}" ) ///
		star(* 0.10 ** 0.05 *** 0.01) ///
		cells("b(fmt(2)star)" "se(fmt(2)par)") ///
		refcat(cat_bcsa_open "\multicolumn{6}{l}{\emph{Panel A: Impact of opening an account (no account at baseline)}}" , nolabel) ///
		order(cat_bcsa_open) ///
		keep(cat_bcsa_open) ///
		scalars("r2 \(R^{2}\)" "Mean_control Average interactions of subjects without account") sfmt(2 2)
			
/****------------------****
Table 2, Panel B 
*****------------------****/

	* Sample
		keep if hh_category==1

	* Variables 
		local x1 random_account
		local x2a "female"
		local x2b "female sc obc fc same_caste age married readwrite_dum emp_agr emp_nonagr self_agr self_nonagr account_total shg_total land_amount dwelling_katcha bcsa_distance trust_strangers"
		local se "vce(bootstrap, reps(400) seed(10101) nodots)"	
		estimates clear
		local y1  n_tr1
		local y2  shop_bcsa
		estimates clear
	
	forvalues a = 1/2 {
	eststo: xtreg `y`a'' `x1' `x2a', fe `se'
		su `y`a'' if random_account==0, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"No"
		estadd local  FE  		"Yes"
		
	eststo: xtreg `y`a'' `x1' `x2b', fe `se'
		su `y`a'' if random_account==0, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"	
		}
		
	**** OUTPUT ****
	* screen
		esttab est*, b(2) p(2) scalars(N "r2 \(R^{2}\)" "Mean_control Average transactions of subjects paid cash" "Control Control variables" "FE Fixed effects") sfmt(0 2 2 0 0) nogaps star(* 0.1 ** 0.05 *** 0.01) 					
	* tex
		esttab est* using results/table2.tex, append f ///
		label booktabs b(3) p(3) eqlabels(none) alignment(S S) collabels("\multicolumn{1}{c}{$\beta$ / SE}" ) ///
		star(* 0.10 ** 0.05 *** 0.01) ///
		cells("b(fmt(2)star)" "se(fmt(2)par)") ///
		refcat(random_account "\multicolumn{6}{l}{\emph{Panel B: Impact of being paid into the account (old account holders)}}" , nolabel) ///
		order(random_account) ///
		keep(random_account) ///
		scalars("N Observations" "r2 \(R^{2}\)" "Mean_control Average interactions of subjects paid in cash" "FE Fixed effects" "Control Control variables") sfmt(0 2 2 0 0)
		
		
/****------------------****------------------****------------------****------------------****------------------****------------------****
Table 3: Impact of opening a bank account on trust and its decomposition
*****------------------****------------------****------------------****------------------****------------------****------------------***/

		use data/lab_sample, clear
		
	* xtset
		xtset village
		
	* prepare text for each line
		label var cat_bcsa_open    	"New account"
		label var random_account	"Paid into account"
		
	* Variables 
		local x1 cat_bcsa_open
		local x2 "random_account female sc obc fc same_caste age married readwrite_dum emp_agr emp_nonagr self_agr self_nonagr account_total shg_total land_amount dwelling_katcha bcsa_distance trust_strangers"								
		local to_use "if hh_category>1"
		local se "vce(bootstrap, reps(400) seed(10101) nodots)"	
		estimates clear
		
/****------------------****
Table 3, Panel A 
*****------------------****/
	
	eststo: xtreg trust_own `x1' `x2' `to_use', fe `se' 
		su trust_own if hh_category==3, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"	
			
	eststo: xtreg trust_own_expected  `x1' `x2' `to_use', fe `se' 
		su trust_own_expected if hh_category==3, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"	
				
	eststo: xtreg dictator_own  `x1' `x2' `to_use', fe `se' 
		su dictator_own if hh_category==3, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"
		
	eststo: xtreg gambles_rejected  `x1' `x2' `to_use', fe `se' 
		su gambles_rejected if hh_category==3, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"	
		
	**** OUTPUT ****
	* screen
		esttab est*, b(2) p(2) scalars(N "r2 \(R^{2}\)" "Mean_control Average trust of subjects without account" "Control Control variables" "FE Fixed Effects") sfmt(0 2 1 0 0) nogaps star(* 0.1 ** 0.05 *** 0.01) 					
	* tex
	
		esttab est* using results/table3.tex, replace f ///
		label booktabs b(3) p(3) eqlabels(none) alignment(S S) collabels("\multicolumn{1}{c}{$\beta$ / SE}" ) ///
		star(* 0.10 ** 0.05 *** 0.01) ///
		cells("b(fmt(2)star)" "se(fmt(2)par)") ///
		refcat(cat_bcsa_open "\multicolumn{6}{l}{\emph{Panel A: The own banker}}" , nolabel) ///
		order(cat_bcsa_open) ///
		keep(cat_bcsa_open) ///
		scalars("r2 \(R^{2}\)" "Mean_control Mean dependent variable of subjects without account") sfmt(2 2)
	
/****------------------****
Table 3, Panel B 
*****------------------****/

	estimates clear
	eststo: xtreg trust_other `x1' `x2' `to_use', fe `se'
		su trust_other if hh_category==3, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"		
		
	eststo: xtreg trust_other_expected `x1' `x2' `to_use', fe `se' 
		su trust_other_expected if hh_category==3, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"	
		
	eststo: xtreg dictator_other  `x1' `x2' `to_use', fe `se' 
		su dictator_other if hh_category==3, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"
			
	eststo: xtreg gambles_rejected  `x1' `x2' `to_use', fe `se' 
		su gambles_rejected if hh_category==3, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"	
		
	**** OUTPUT ****
	* screen
		esttab est*, b(2) p(2) scalars(N "r2 \(R^{2}\)" "Mean_control Average trust of subjects without account" "Control Control variables" "FE Fixed Effects") sfmt(0 2 1 0 0) nogaps star(* 0.1 ** 0.05 *** 0.01) 					
	* tex 
		esttab est* using results/table3.tex, append f ///
		label booktabs b(3) p(3) eqlabels(none) alignment(S S) collabels("\multicolumn{1}{c}{$\beta$ / SE}" ) ///
		star(* 0.10 ** 0.05 *** 0.01) ///
		cells("b(fmt(2)star)" "se(fmt(2)par)") ///
		refcat(cat_bcsa_open "\multicolumn{6}{l}{\emph{Panel B: The other banker}}" , nolabel) ///
		order(cat_bcsa_open) ///
		keep(cat_bcsa_open) ///
		scalars("r2 \(R^{2}\)" "Mean_control Mean dependent variable of subjects without account" "N Observations"  "FE Fixed effects" "Control Control variables") sfmt(2 2 0 0 0)
			
			
/****------------------****------------------****------------------****
Table 4: Correlation between trust and the final account balance at the end of Phase 2
*****------------------****------------------****------------------****/

	use data/admin_data, clear
	keep hhn_long pre_bal_1 final_2
	merge 1:1 hhn_long using data/lab_sample
	keep if _merge==3
	drop if hh_category==3
	
	* xtset
		xtset village
	* prepare text for each line
		label var trust_dum_own 			"Sent positive amount in trust game"
		label var trust_dum_other 			"Sent positive amount in trust game"	
		label var trust_own_expected_dum	"Expects back the amount sent in trust game"
		label var trust_other_expected_dum	"Expects back the amount sent in trust game"
		label var dictator_dum_own 			"Sent positive amount in dictator game"	
		label var dictator_dum_other		"Sent positive amount in dictator game"	
		label var gambles_rejected			"Risk aversion" 
		label var cat_bcsa_open				"New account"
		label var random_account 			"Paid into account"
		label var female 					"Woman"
		
	* Variables 
		local x2 "cat_bcsa_open random_account female sc obc fc same_caste age married readwrite_dum emp_agr emp_nonagr self_agr self_nonagr account_total shg_total land_amount dwelling_katcha bcsa_distance trust_strangers pre_bal_1 weeks"
		local se "vce(bootstrap, reps(400) seed(10101) nodots)"	
		
/****------------------****
Table 4, Panel A 
*****------------------****/

	estimates clear	
	eststo: xtreg final_2 trust_dum_own `x2', fe `se' 
		su final_2 if trust_dum_own==0, d
		estadd scalar Mean_control = `r(mean)'	
		estadd local  FE  		"Yes"	
		estadd local  Control 	"Yes"	
		
	eststo: xtreg final_2 trust_own_expected_dum `x2', fe `se' 
		su final_2 if trust_own_expected_dum==0, d
		estadd scalar Mean_control = `r(mean)'	
		estadd local  FE  		"Yes"	
		estadd local  Control 	"Yes"	

	eststo: xtreg final_2 dictator_dum_own `x2', fe `se' 
		su final_2 if dictator_dum_own==0, d
		estadd scalar Mean_control = `r(mean)'	
		estadd local  FE  		"Yes"	
		estadd local  Control 	"Yes"
	
	eststo: xtreg final_2 gambles_rejected `x2', fe `se' 
		su final_2 if gambles_rejected==0, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  FE  		"Yes"
		estadd local  Control 	"Yes"
		
	eststo: xtreg final_2 trust_own_expected_dum dictator_dum_own gambles_rejected `x2', fe `se' 
		su final_2 if trust_own_expected_dum==0 & dictator_dum_own==0 & gambles_rejected==0, d
		estadd scalar Mean_control = `r(mean)'		
		estadd local  FE  		"Yes"
		estadd local  Control 	"Yes"
		
	**** OUTPUT ****
	* screen
		esttab est*, b(2) p(2) scalars(N "r2 \(R^{2}\)" "Mean_control Average trust of subjects without account" "Control Control variables" "FE Fixed Effects") sfmt(0 2 2 0 0) nogaps star(* 0.1 ** 0.05 *** 0.01) 					
	* tex
		esttab est* using results/table4.tex, replace f ///
		label booktabs b(3) p(3) eqlabels(none) alignment(S S) collabels("\multicolumn{1}{c}{$\beta$ / SE}" ) ///
		star(* 0.10 ** 0.05 *** 0.01) ///
		cells("b(fmt(2)star)" "se(fmt(2)par)") ///
		refcat(trust_dum_own "\multicolumn{6}{l}{\emph{Panel A: Lab games with own banker}}" , nolabel) ///
		order(trust_dum_own trust_own_expected_dum dictator_dum_own gambles_rejected) ///
		keep(trust_dum_own trust_own_expected_dum dictator_dum_own gambles_rejected) ///
		scalars("r2 \(R^{2}\)" "Mean_control Final balance if covariates of interest equal 0") sfmt(2 2)
	
/****------------------****
Table 4, Panel B 
*****------------------****/

	estimates clear		
	eststo: xtreg final_2 trust_dum_other `x2', fe `se'
		su final_2 if trust_dum_other==0, d
		estadd scalar Mean_control = `r(mean)'	
		estadd local  FE  		"Yes"	
		estadd local  Control 	"Yes"	
	
	eststo: xtreg final_2 trust_other_expected_dum `x2', fe `se' 
		su final_2 if trust_other_expected_dum==0, d
		estadd scalar Mean_control = `r(mean)'	
		estadd local  FE  		"Yes"	
		estadd local  Control 	"Yes"	
	
	eststo: xtreg final_2 dictator_dum_other `x2', fe `se' 
		su final_2 if dictator_dum_other==0, d
		estadd scalar Mean_control = `r(mean)'	
		estadd local  FE  		"Yes"	
		estadd local  Control 	"Yes"
		
	eststo: xtreg final_2 gambles_rejected `x2', fe `se' 
		su final_2 if gambles_rejected==0, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  FE  		"Yes"
		estadd local  Control 	"Yes"
		
	eststo: xtreg final_2 trust_other_expected_dum dictator_dum_other gambles_rejected `x2', fe `se' 
		su final_2 if trust_other_expected_dum==0 & dictator_dum_other==0 & gambles_rejected==0, d
		estadd scalar Mean_control = `r(mean)'				
		estadd local  FE  		"Yes"
		estadd local  Control 	"Yes"		
		
	**** OUTPUT ****
	* screen
		esttab est*, b(2) p(2) scalars(N "r2 \(R^{2}\)" "Mean_control Average trust of subjects without account" "Control Control variables" "FE Fixed Effects") sfmt(0 2 2 0 0) nogaps star(* 0.1 ** 0.05 *** 0.01) 					
	* tex
		esttab est* using results/table4.tex, append f ///
		label booktabs b(3) p(3) eqlabels(none) alignment(S S) collabels("\multicolumn{1}{c}{$\beta$ / SE}" ) ///
		star(* 0.10 ** 0.05 *** 0.01) ///
		cells("b(fmt(2)star)" "se(fmt(2)par)") ///
		refcat(trust_dum_other "\multicolumn{6}{l}{\emph{Panel B: Lab games with other banker}}" , nolabel) ///
		order(trust_dum_other trust_other_expected_dum dictator_dum_other gambles_rejected) ///
		keep(trust_dum_other trust_other_expected_dum dictator_dum_other gambles_rejected) ///
		scalars("r2 \(R^{2}\)" "Mean_control Final balance if covariates of interest equal 0" "N Observations"  "FE Fixed effects" "Control Control variables") sfmt(2 2 0 0 0)
			
			
/****------------------****------------------****------------------****------------------****---------------****
* Table 5: Summary statistics and balance check of baseline characteristics - Part 1
****------------------****------------------****------------------****------------------****---------------****/

	use data/lab_sample, clear
	drop if hh_category==1
	
* PREPARE TEXT FOR EACH LINE
	label var cat_bcsa_open		"New account (%)"
	label var female 			"Woman (%)"
	label var st				"Caste category: ST (%)"
	label var sc 				"Caste category: SC (%)"
	label var obc 				"Caste category: OBC (%)"
	label var fc 				"Caste category: FC (%)"
	label var same_caste		"Same caste category as BCSA (\%)"
	label var land_amount  		"Land (acres)"
	label var married   		"Married (%)"
	label var readwrite_dum  	"Literate (%)"
	label var age 				"Age"
	label var emp_agr  			"Wage labor in agriculture (%)"
	label var emp_nonagr  		"Wage labor outside agriculture (%)"
	label var self_agr  		"Self-employed in agriculture (%)"
	label var self_nonagr  		"Self-employed outside agriculture (%)"
	label var account_total  	"Accounts held (#)"
	label var shg_total  		"Savings groups (#)"
	label var dwelling_katcha  	"Dwelling type: katcha (%)"
	label var bcsa_distance 	"Distance to the BCSA (km)"
	label var trust_strangers  	"Cautious with strangers (%)"
	label var weeks  			"Weeks interviewed (#)"
	
* COLUMN 1: SAMPLE MEAN 
	*multiply dummies by 100 to get percentages
		foreach x of var cat_bcsa_open female st sc obc fc same_caste married readwrite_dum emp_agr emp_nonagr self_agr self_nonagr dwelling_katcha trust_strangers{
		replace `x' = `x'*100
		}
		
	estimates clear
	local var cat_bcsa_open female st sc obc fc same_caste land_amount married readwrite_dum age emp_agr emp_nonagr self_agr self_nonagr account_total shg_total dwelling_katcha bcsa_distance trust_strangers weeks
		estpost su `var'  
		est store A

	esttab A using results/table5_mean1.csv, replace label cells(mean(fmt(1)) sd(fmt(1) par)) nonum collabels(none)   f noobs   stats(N, fmt(%18.0g))
	*remake dummies dummies
		foreach x of var cat_bcsa_open female st sc obc fc same_caste married readwrite_dum emp_agr emp_nonagr self_agr self_nonagr dwelling_katcha trust_strangers{
		replace `x' = `x'/100
		}
		
* COLUMN 2: COEFFICIENT 
	estimates clear
	foreach X in female st sc obc fc same_caste land_amount married readwrite_dum age emp_agr emp_nonagr self_agr self_nonagr account_total shg_total dwelling_katcha bcsa_distance trust_strangers weeks{ 
	quiet reg `X' cat_bcsa_open 
	estimates store `X'1
	}
	esttab female1 st1 sc1 obc1 fc1 same_caste1 land_amount1 married1 readwrite_dum1 age1 emp_agr1 emp_nonagr1 self_agr1 self_nonagr1 account_total1 shg_total1 dwelling_katcha1 bcsa_distance1 trust_strangers1 weeks1 using results/table5_reg1.csv, replace b(2) keep(cat_bcsa_open) se(2) scalars(N) nogaps star(* 0.1 ** 0.05 *** 0.01) wide

	
/****------------------****------------------****------------------****------------------****---------------****
* Table 5: Summary statistics and balance check of baseline characteristics - Part 2
****------------------****------------------****------------------****------------------****---------------****/

	use data/admin_data, clear
	keep hhn_long pre_bal_1 
	merge 1:1 hhn_long using data/lab_sample
	keep if _merge==3
	keep if hh_category==1

* PREPARE TEXT FOR EACH LINE
	label var random_account 	"Paid into account (%)"
	label var female 			"Woman (%)"
	label var st				"Caste category: ST (%)"
	label var sc 				"Caste category: SC (%)"
	label var obc 				"Caste category: OBC (%)"
	label var fc 				"Caste category: FC (%)"
	label var same_caste		"Same caste category as BCSA (\%)"
	label var land_amount  		"Land (acres)"
	label var married   		"Married (%)"
	label var readwrite_dum  	"Literate (%)"
	label var age 				"Age"
	label var emp_agr  			"Wage labor in agriculture (%)"
	label var emp_nonagr  		"Wage labor outside agriculture (%)"
	label var self_agr  		"Self-employed in agriculture (%)"
	label var self_nonagr  		"Self-employed outside agriculture (%)"
	label var account_total  	"Accounts held (#)"
	label var shg_total  		"Savings groups (#)"
	label var dwelling_katcha  	"Dwelling type: katcha (%)"
	label var bcsa_distance 	"Distance to the BCSA (km)"
	label var trust_strangers  	"Cautious with strangers (%)"
	label var pre_bal_1			"Balance on BCSA account before start weekly surveys (Rs)"
	label var weeks  			"Weeks interviewed (#)"
	
* COLUMN 3: SAMPLE MEAN 
	*multiply dummies by 100 to get percentages
		foreach x of var random_account female st sc obc fc same_caste married readwrite_dum emp_agr emp_nonagr self_agr self_nonagr dwelling_katcha trust_strangers{
		replace `x' = `x'*100
		}
		
	estimates clear
	local var random_account female st sc obc fc same_caste land_amount married readwrite_dum age emp_agr emp_nonagr self_agr self_nonagr account_total shg_total dwelling_katcha bcsa_distance trust_strangers pre_bal_1 weeks
		estpost su `var'  
		est store A

	esttab A using results/table5_mean2.csv, replace label cells(mean(fmt(1)) sd(fmt(1) par)) nonum collabels(none)   f noobs   stats(N, fmt(%18.0g))
	*remake dummies dummies
		foreach x of var random_account female st sc obc fc same_caste married readwrite_dum emp_agr emp_nonagr self_agr self_nonagr dwelling_katcha trust_strangers{
		replace `x' = `x'/100
		}
		
* COLUMN 4: COEFFICIENT 
	estimates clear
	foreach X in female st sc obc fc same_caste land_amount married readwrite_dum age emp_agr emp_nonagr self_agr self_nonagr account_total shg_total dwelling_katcha bcsa_distance trust_strangers pre_bal_1 weeks{ 
	quiet reg `X' random_account 
	estimates store `X'1
	}
	esttab female1 st1 sc1 obc1 fc1 same_caste1 land_amount1 married1 readwrite_dum1 age1 emp_agr1 emp_nonagr1 self_agr1 self_nonagr1 account_total1 shg_total1 dwelling_katcha1 bcsa_distance1 trust_strangers1 pre_bal_11 weeks1 using results/table5_reg2.csv, replace b(2) keep(random_account) se(2) scalars(N) nogaps star(* 0.1 ** 0.05 *** 0.01) wide
	
	
/****------------------****------------------****------------------****------------------****---------------****
* Table 6: Summary statistics and differences between old and new account holders
****------------------****------------------****------------------****------------------****---------------****/

	use data/admin_data, clear
	keep hhn_long pre_bal_1 
	merge 1:1 hhn_long using data/lab_sample
	drop if _merge==1
	replace pre_bal_1 = 0 if _merge==2

* PREPARE TEXT FOR EACH LINE
	label var cat_bcsa 			"Had account already (%)"
	label var female 			"Woman (%)"
	label var st				"Caste category: ST (%)"
	label var sc 				"Caste category: SC (%)"
	label var obc 				"Caste category: OBC (%)"
	label var fc 				"Caste category: FC (%)"
	label var same_caste		"Same caste category as BCSA (\%)"
	label var land_amount  		"Land (acres)"
	label var married   		"Married (%)"
	label var readwrite_dum  	"Literate (%)"
	label var age 				"Age"
	label var emp_agr  			"Wage labor in agriculture (%)"
	label var emp_nonagr  		"Wage labor outside agriculture (%)"
	label var self_agr  		"Self-employed in agriculture (%)"
	label var self_nonagr  		"Self-employed outside agriculture (%)"
	label var account_total  	"Accounts held (#)"
	label var shg_total  		"Savings groups (#)"
	label var dwelling_katcha  	"Dwelling type: katcha (%)"
	label var bcsa_distance 	"Distance to the BCSA (km)"
	label var trust_strangers  	"Cautious with strangers (%)"	
	label var pre_bal_1			"Balance on BCSA account before start weekly surveys (Rs)"
	label var weeks  			"Weeks interviewed (#)"
	
* COLUMN 1: SAMPLE MEAN 
	*multiply dummies by 100 to get percentages
		foreach x of var cat_bcsa female st sc obc fc same_caste married readwrite_dum emp_agr emp_nonagr self_agr self_nonagr dwelling_katcha trust_strangers{
		replace `x' = `x'*100
		}
		
	estimates clear
	local var cat_bcsa female st sc obc fc same_caste land_amount married readwrite_dum age emp_agr emp_nonagr self_agr self_nonagr account_total shg_total dwelling_katcha bcsa_distance trust_strangers pre_bal_1 weeks
		estpost su `var'  
		est store A

	esttab A using results/table6_mean.csv, replace label cells(mean(fmt(1)) sd(fmt(1) par)) nonum collabels(none)   f noobs   stats(N, fmt(%18.0g))
	*remake dummies dummies
		foreach x of var cat_bcsa female st sc obc fc same_caste married readwrite_dum emp_agr emp_nonagr self_agr self_nonagr dwelling_katcha trust_strangers{
		replace `x' = `x'/100
		}
		
* COLUMN 2: COEFFICIENT 
	estimates clear
	foreach X in female st sc obc fc same_caste land_amount married readwrite_dum age emp_agr emp_nonagr self_agr self_nonagr account_total shg_total dwelling_katcha bcsa_distance trust_strangers pre_bal_1 weeks{ 
	quiet reg `X' cat_bcsa 
	estimates store `X'1
	}
	esttab female1 st1 sc1 obc1 fc1 same_caste1 land_amount1 married1 readwrite_dum1 age1 emp_agr1 emp_nonagr1 self_agr1 self_nonagr1 account_total1 shg_total1 dwelling_katcha1 bcsa_distance1 trust_strangers1 pre_bal_11 weeks1 using results/table6_reg.csv, replace b(2) keep(cat_bcsa) se(2) scalars(N) nogaps star(* 0.1 ** 0.05 *** 0.01) wide

			
/****------------------****------------------****------------------****------------------****------------------****------------------****
Table 7: Test for differential attrition in the lab games
*****------------------****------------------****------------------****------------------****------------------****------------------***/

	use data/full_sample.dta, clear 
		
	* xtset
		xtset village
		
	* prepare text for each line
		label var cat_bcsa_open    	"New account"
		label var random_account	"Paid into account"
	
	* Variables
		replace lab_consent = 0 if lab_consent!=1
		replace lab_consent = 0 if gambles_rejected==. // attrition dummy=1 if subjects did not participate in all 5 lab games

		local x1 "cat_bcsa_open random_account"
		local x2 "sc obc same_caste age married readwrite_dum emp_agr emp_nonagr self_agr self_nonagr account_total shg_total land_amount dwelling_katcha bcsa_distance trust_strangers"								
		local se "vce(bootstrap, reps(400) seed(10101) nodots)"	
		estimates clear
		
	
	probit lab_consent `x1' female i.village,  `se' 
	eststo: margins, dydx(*) post	
		estadd local  Control 	"No"
		estadd local  FE  		"Yes"	
	
	probit lab_consent `x1' female `x2' i.village,  `se' 
	eststo: margins, dydx(*) post	
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"	
		
	test  `x1' female `x2'
	test  female `x2'
		
	**** OUTPUT ****
	* screen
		esttab est*, b(2) p(2) scalars(N "r2 \(R^{2}\)" "Mean_control Average trust of subjects without account" "Control Control variables" "FE Fixed Effects") sfmt(0 2 1 0 0) nogaps star(* 0.1 ** 0.05 *** 0.01) 					
	* tex
		esttab est* using results/table7.tex, replace f ///
		label booktabs b(3) p(3) eqlabels(none) alignment(S S) collabels("\multicolumn{1}{c}{$\beta$ / SE}" ) ///
		star(* 0.10 ** 0.05 *** 0.01) ///
		cells("b(fmt(2)star)" "se(fmt(2)par)") ///
		refcat(cat_bcsa_open random_account "\multicolumn{6}{l}{\emph{Panel A: The own banker}}" , nolabel) ///
		order(cat_bcsa_open random_account) ///
		keep(cat_bcsa_open random_account) ///
		scalars("r2 \(R^{2}\)" "Mean_control Mean dependent variable of subjects without account") sfmt(2 1)
	
	
/****------------------****------------------****------------------****------------------****------------------****------------------****
Table 8: Impact of opening a bank account on trust and its decomposition - without control variables
*****------------------****------------------****------------------****------------------****------------------****------------------***/

		use data/lab_sample, clear
		
	* xtset
		xtset village
		
	* prepare text for each line
		label var cat_bcsa_open    	"New account"
		label var random_account	"Paid into account"
		
	* Variables 
		local x1 cat_bcsa_open
		local x2 "random_account female"
		local to_use "if hh_category>1"
		local se "vce(bootstrap, reps(400) seed(10101) nodots)"	
		estimates clear
			
/****------------------****
Table 8, Panel A 
*****------------------****/

	eststo: xtreg trust_own `x1' `x2' `to_use', fe `se' 
		su trust_own if hh_category==3, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"	
			
	eststo: xtreg trust_own_expected  `x1' `x2' `to_use', fe `se' 
		su trust_own_expected if hh_category==3, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"	
				
	eststo: xtreg dictator_own  `x1' `x2' `to_use', fe `se' 
		su dictator_own if hh_category==3, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"
		
	eststo: xtreg gambles_rejected  `x1' `x2' `to_use', fe `se' 
		su gambles_rejected if hh_category==3, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"	
		
	**** OUTPUT ****
	* screen
		esttab est*, b(2) se(2) scalars(N "r2 \(R^{2}\)" "Mean_control Average trust of subjects without account" "Control Control variables" "FE Fixed Effects") sfmt(0 2 2 0 0) nogaps star(* 0.1 ** 0.05 *** 0.01) 					
	* tex
		esttab est* using results/table8.tex, replace f ///
		label booktabs b(3) p(3) eqlabels(none) alignment(S S) collabels("\multicolumn{1}{c}{$\beta$ / SE}" ) ///
		star(* 0.10 ** 0.05 *** 0.01) ///
		cells("b(fmt(2)star)" "se(fmt(2)par)") ///
		refcat(cat_bcsa_open "\multicolumn{6}{l}{\emph{Panel A: Lab games with own banker}}" , nolabel) ///
		order(cat_bcsa_open) ///
		keep(cat_bcsa_open) ///
		scalars("r2 \(R^{2}\)" "Mean_control Mean dependent variable of subjects without account") sfmt(2 2)

/****------------------****
Table 8, Panel B 
*****------------------****/
	
	estimates clear	
	eststo: xtreg trust_other `x1' `x2' `to_use', fe `se'
		su trust_other if hh_category==3, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"		
		
	eststo: xtreg trust_other_expected `x1' `x2' `to_use', fe `se' 
		su trust_other_expected if hh_category==3, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"	
		
	eststo: xtreg dictator_other  `x1' `x2' `to_use', fe `se' 
		su dictator_other if hh_category==3, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"
			
	eststo: xtreg gambles_rejected  `x1' `x2' `to_use', fe `se' 
		su gambles_rejected if hh_category==3, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"	
		
	**** OUTPUT ****
	* screen
		esttab est*, b(2) se(2) scalars(N "r2 \(R^{2}\)" "Mean_control Average trust of subjects without account" "Control Control variables" "FE Fixed Effects") sfmt(0 2 2 0 0) nogaps star(* 0.1 ** 0.05 *** 0.01) 					
	* tex
		esttab est* using results/table8.tex, append f ///
		label booktabs b(3) p(3) eqlabels(none) alignment(S S) collabels("\multicolumn{1}{c}{$\beta$ / SE}" ) ///
		star(* 0.10 ** 0.05 *** 0.01) ///
		cells("b(fmt(2)star)" "se(fmt(2)par)") ///
		refcat(cat_bcsa_open "\multicolumn{6}{l}{\emph{Panel B: Lab games with other banker}}" , nolabel) ///
		order(cat_bcsa_open) ///
		keep(cat_bcsa_open) ///
		scalars("r2 \(R^{2}\)" "Mean_control Mean dependent variable of subjects without account" "N Observations" "FE Fixed effects" "Control Control variables") sfmt(2 2 0 0 0)
			
/****------------------****------------------****------------------****------------------****------------------****------------------****
Table 9: Impact of being paid into the account on trust and its decomposition - old account holders
*****------------------****------------------****------------------****------------------****------------------****------------------***/

		use data/lab_sample, clear
		
	* sample
		keep if hh_category==1
		drop if gambles_rejected==.
		
	* xtset
		xtset village
		
	* prepare text for each line
		label var cat_bcsa_open    	"New account"
		label var random_account	"Paid into account"
		
	* Variables 
		local x1 random_account
		local x2 "female sc obc fc same_caste age married readwrite_dum emp_agr emp_nonagr self_agr self_nonagr account_total shg_total land_amount dwelling_katcha bcsa_distance trust_strangers"
		local se "vce(bootstrap, reps(400) seed(10101) nodots)"	
		estimates clear
		
/****------------------****
Table 9, Panel A
*****------------------****/
	
	eststo: xtreg trust_own `x1' `x2', fe `se' 
		su trust_own if random_account==0, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"	
			
	eststo: xtreg trust_own_expected  `x1' `x2', fe `se' 
		su trust_own_expected if random_account==0, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"	
				
	eststo: xtreg dictator_own  `x1' `x2', fe `se' 
		su dictator_own if random_account==0, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"
		
	eststo: xtreg gambles_rejected  `x1' `x2', fe `se' 
		su gambles_rejected if random_account==0, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"	
			
	**** OUTPUT ****
	* screen
		esttab est*, b(2) p(2) scalars(N "r2 \(R^{2}\)" "Mean_control Average trust of subjects without account" "Control Control variables" "FE Fixed Effects") sfmt(0 2 1 0 0) nogaps star(* 0.1 ** 0.05 *** 0.01) 					
	* tex
		esttab est* using results/table9.tex, replace f ///
		label booktabs b(3) p(3) eqlabels(none) alignment(S S) collabels("\multicolumn{1}{c}{$\beta$ / SE}" ) ///
		star(* 0.10 ** 0.05 *** 0.01) ///
		cells("b(fmt(2)star)" "se(fmt(2)par)") ///
		refcat(random_account "\multicolumn{6}{l}{\emph{Panel A: Lab games with own banker}}" , nolabel) ///
		order(random_account) ///
		keep(random_account) ///
		scalars("r2 \(R^{2}\)" "Mean_control Mean dependent variable of subjects paid in cash") sfmt(2 2)
	
/****------------------****
Table 9, Panel B 
*****------------------****/
	
	estimates clear	
	eststo: xtreg trust_other `x1' `x2', fe `se'
		su trust_other if random_account==0, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"		
		
	eststo: xtreg trust_other_expected `x1' `x2', fe `se' 
		su trust_other_expected if random_account==0, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"	
		
	eststo: xtreg dictator_other  `x1' `x2', fe `se' 
		su dictator_other if random_account==0, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"
			
	eststo: xtreg gambles_rejected  `x1' `x2', fe `se' 
		su gambles_rejected if random_account==0, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  Control 	"Yes"
		estadd local  FE  		"Yes"	
		
	**** OUTPUT ****
	* screen
		esttab est*, b(2) p(2) scalars(N "r2 \(R^{2}\)" "Mean_control Average trust of subjects without account" "Control Control variables" "FE Fixed Effects") sfmt(0 2 1 0 0) nogaps star(* 0.1 ** 0.05 *** 0.01) 					
	* tex
		esttab est* using results/table9.tex, append f ///
		label booktabs b(3) p(3) eqlabels(none) alignment(S S) collabels("\multicolumn{1}{c}{$\beta$ / SE}" ) ///
		star(* 0.10 ** 0.05 *** 0.01) ///
		cells("b(fmt(2)star)" "se(fmt(2)par)") ///
		refcat(random_account "\multicolumn{6}{l}{\emph{Panel B: Lab games with other banker}}" , nolabel) ///
		order(random_account) ///
		keep(random_account) ///
		scalars("r2 \(R^{2}\)" "Mean_control Mean dependent variable of subjects paid in cash" "N Observations" "FE Fixed effects" "Control Control variables") sfmt(2 2 0 0 0)
				
		
/****------------------****------------------****------------------****
Table 10: Correlation between trust and the average account balance during Phase 2 
*****------------------****------------------****------------------****/

	use data/admin_data, clear
	keep hhn_long pre_bal_1 average_2
	merge 1:1 hhn_long using data/lab_sample
	keep if _merge==3
	drop if hh_category==3
	
	* xtset
		xtset village
	* prepare text for each line
		label var trust_dum_own 			"Sent positive amount in trust game"
		label var trust_dum_other 			"Sent positive amount in trust game"	
		label var trust_own_expected_dum	"Expects back the amount sent in trust game"
		label var trust_other_expected_dum	"Expects back the amount sent in trust game"
		label var dictator_dum_own 			"Sent positive amount in dictator game"	
		label var dictator_dum_other		"Sent positive amount in dictator game"	
		label var gambles_rejected			"Risk aversion" 
		label var cat_bcsa_open				"New account"
		label var random_account 			"Paid into account"
		label var female 					"Woman"
		
	* Variables 
		local x2 "cat_bcsa_open random_account female sc obc fc same_caste age married readwrite_dum emp_agr emp_nonagr self_agr self_nonagr account_total shg_total land_amount dwelling_katcha bcsa_distance trust_strangers pre_bal_1 weeks"
		local se "vce(bootstrap, reps(400) seed(10101) nodots)"	
				
/****------------------****
Table 10, Panel A 
*****------------------****/
	
	estimates clear	
	eststo: xtreg average_2 trust_dum_own `x2', fe `se' 
		su average_2 if trust_dum_own==0, d
		estadd scalar Mean_control = `r(mean)'	
		estadd local  FE  		"Yes"	
		estadd local  Control 	"Yes"
		
	eststo: xtreg average_2 trust_own_expected_dum `x2', fe `se' 
		su average_2 if trust_own_expected_dum==0, d
		estadd scalar Mean_control = `r(mean)'	
		estadd local  FE  		"Yes"	
		estadd local  Control 	"Yes"	
		
	eststo: xtreg average_2 dictator_dum_own `x2', fe `se' 
		su average_2 if dictator_dum_own==0, d
		estadd scalar Mean_control = `r(mean)'	
		estadd local  FE  		"Yes"	
		estadd local  Control 	"Yes"
		
	eststo: xtreg average_2 gambles_rejected `x2', fe `se' 
		su average_2 if gambles_rejected==0, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  FE  		"Yes"
		estadd local  Control 	"Yes"
		
	eststo: xtreg average_2 trust_own_expected_dum dictator_dum_own gambles_rejected `x2', fe `se' 
		su average_2 if trust_own_expected_dum==0 & dictator_dum_own==0 & gambles_rejected==0, d
		estadd scalar Mean_control = `r(mean)'		
		estadd local  FE  		"Yes"
		estadd local  Control 	"Yes"	
		
	**** OUTPUT ****
	* screen
		esttab est*, b(2) p(2) scalars(N "r2 \(R^{2}\)" "Mean_control Average trust of subjects without account" "Control Control variables" "FE Fixed Effects") sfmt(0 2 2 0 0) nogaps star(* 0.1 ** 0.05 *** 0.01) 					
	* tex
		esttab est* using results/table10.tex, replace f ///
		label booktabs b(3) p(3) eqlabels(none) alignment(S S) collabels("\multicolumn{1}{c}{$\beta$ / SE}" ) ///
		star(* 0.10 ** 0.05 *** 0.01) ///
		cells("b(fmt(2)star)" "se(fmt(2)par)") ///
		refcat(trust_dum_own "\multicolumn{6}{l}{\emph{Panel A: Lab games with own banker}}" , nolabel) ///
		order(trust_dum_own trust_own_expected_dum dictator_dum_own gambles_rejected) ///
		keep(trust_dum_own trust_own_expected_dum dictator_dum_own gambles_rejected) ///
		scalars("r2 \(R^{2}\)" "Mean_control Average balance if covariates of interest equal 0") sfmt(2 2)

/****------------------****
Table 10, Panel B 
*****------------------****/
		
	estimates clear	
	eststo: xtreg average_2 trust_dum_other `x2', fe `se' 
		su average_2 if trust_dum_other==0, d
		estadd scalar Mean_control = `r(mean)'	
		estadd local  FE  		"Yes"	
		estadd local  Control 	"Yes"		

	eststo: xtreg average_2 trust_other_expected_dum `x2', fe `se' 
		su average_2 if trust_other_expected_dum==0, d
		estadd scalar Mean_control = `r(mean)'	
		estadd local  FE  		"Yes"	
		estadd local  Control 	"Yes"	
	
	eststo: xtreg average_2 dictator_dum_other `x2', fe `se' 
		su average_2 if dictator_dum_other==0, d
		estadd scalar Mean_control = `r(mean)'	
		estadd local  FE  		"Yes"	
		estadd local  Control 	"Yes"
		
	eststo: xtreg average_2 gambles_rejected `x2', fe `se' 
		su average_2 if gambles_rejected==0, d
		estadd scalar Mean_control = `r(mean)'
		estadd local  FE  		"Yes"
		estadd local  Control 	"Yes"
					
	eststo: xtreg average_2 trust_other_expected_dum dictator_dum_other gambles_rejected `x2', fe `se' 
		su average_2 if trust_other_expected_dum==0 & dictator_dum_other==0 & gambles_rejected==0, d
		estadd scalar Mean_control = `r(mean)'				
		estadd local  FE  		"Yes"
		estadd local  Control 	"Yes"
		
	**** OUTPUT ****
	* screen
		esttab est*, b(2) p(2) scalars(N "r2 \(R^{2}\)" "Mean_control Average trust of subjects without account" "Control Control variables" "FE Fixed Effects") sfmt(0 2 1 0 0) nogaps star(* 0.1 ** 0.05 *** 0.01) 					
	* tex
		esttab est* using results/table10.tex, append f ///
		label booktabs b(3) p(3) eqlabels(none) alignment(S S) collabels("\multicolumn{1}{c}{$\beta$ / SE}" ) ///
		star(* 0.10 ** 0.05 *** 0.01) ///
		cells("b(fmt(2)star)" "se(fmt(2)par)") ///
		refcat(trust_dum_other "\multicolumn{6}{l}{\emph{Panel B: Lab games with other banker}}" , nolabel) ///
		order(trust_dum_other trust_other_expected_dum dictator_dum_other gambles_rejected) ///
		keep(trust_dum_other trust_other_expected_dum dictator_dum_other gambles_rejected) ///
		scalars("r2 \(R^{2}\)" "Mean_control Average balance if covariates of interest equal 0" "N Observations"  "FE Fixed effects" "Control Control variables") sfmt(2 2 0 0 0)
			
			
			
		
		
		